<template>
  <common-info-dialog
    :title="title"
    :visible.sync="detailsOpen"
    @cancel="cancel"
  >
    <common-info-table>
      <common-info-table-cell label="系统编码" width="50%">
        {{ form.businessCode }}
      </common-info-table-cell>
      <common-info-table-cell label="系统名称" width="50%">
        {{ form.businessName }}
      </common-info-table-cell>
      <common-info-table-cell label="负责人" width="50%">
        {{ form.userCode }}
      </common-info-table-cell>
      <common-info-table-cell label="通信等级" width="50%">
        {{ changeVal(form.communicationLevel) }}
      </common-info-table-cell>
      <common-info-table-cell label="用途">
        {{ form.businessUse }}
      </common-info-table-cell>
      <common-info-table-cell label="简介">
        {{ form.introduce }}
      </common-info-table-cell>
    </common-info-table>
  </common-info-dialog>
</template>

<script>
import { getInfo } from "@/api/system/businessSystem/businessSystem";
export default {
  name: "detail",
  data() {
    return {
      title: "详情",
      detailsOpen: false,
      form: {
        businessCode: "",
        businessName: "",
        userCode: "",
        administrator: "",
        communicationLevel: null,
        businessUse: "",
        remark: "",
        isDefault: "N",
      },
      queryLevelList: [
        {
          label: "一级",
          value: 1,
        },
        {
          label: "二级",
          value: 2,
        },
        {
          label: "三级",
          value: 3,
        },
      ],
    };
  },
  methods: {
    cancel() {
      this.reset();
      this.detailsOpen = false;
    },
    reset() {
      this.form = {
        businessCode: "",
        businessName: "",
        userCode: "",
        administrator: "",
        communicationLevel: null,
        businessUse: "",
        remark: "",
        isDefault: "N",
      };
    },
    showDetail(id) {
      getInfo({ id }).then((res) => {
        if (res && res.code === 200) {
          this.form = res.data;
          this.detailsOpen = true;
        } else {
          this.$GlobalErrorConfirm("数据加载失败", res.msg);
        }
      });
    },
    changeVal(val) {
      return this.queryLevelList.find((item) => item.value === val)?.label;
    },
  },
};
</script>

<style scoped></style>
